local skel = fk.CreateSkill{
  name = "tea__raoguo",
  tags = { Skill.Compulsory }
}
---@type TargetModSpec
local raoguo = {
  bypass_times = function(self, player, skill, scope, card, to)
    return player:hasSkill("tea__raoguo") and (skel.trueName == "slash_skill" or card:isCommonTrick())
  end,
  bypass_distances =  function(self, player, skill, card, to)
    return player:hasSkill("tea__raoguo") and (skel.trueName == "slash_skill"or card:isCommonTrick())
  end,
}
---@type ProhibitSpec
local raoguo_prohibit = {
  is_prohibited = function(self, from, to, card)
    if (card.trueName == "slash" or card:isCommonTrick()) and from:hasSkill(skel.name) then
      local fathest = 0
      local targets = {}
      for _, p in ipairs(Fk:currentRoom().alive_players) do
        if from ~= p and from:inMyAttackRange(p) then
          local distance = p:distanceTo(from)
          if distance > fathest then
            fathest = distance
            targets = { p.id }
          elseif distance == fathest then
            table.insert(targets, p.id)
          end
        end
      end
      return not table.contains(targets, to.id)
    end
  end,
}
---@type TrigSkelSpec<UseCardFunc>
local raoguo_refresh = {
  can_refresh = function (self, event, target, player, data)
    return player == target and player:hasSkill(skel.name) and (data.card and data.card.trueName == "slash" or data.card.skill == "slash_skill" or data.card:isCommonTrick())
  end,
  on_refresh = function (self, event, target, player, data)
    player.room:notifySkillInvoked(player, skel.name, "offensive")
    player:broadcastSkillInvoke(skel.name)
  end
}
skel:addEffect("targetmod", raoguo)
skel:addEffect("prohibit", raoguo_prohibit)
skel:addEffect(fk.PreCardUse, raoguo_refresh)
return skel